﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace DGMResourcesTool.Logic
{
    public class LogUtility
    {
        /// <summary>
        /// 写入log.
        /// </summary>
        public static void AddToLog(string desc)
        {
            MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
            mainWindow?.LogFrame.Items.Add("[" + DateTime.Now.ToString("HH:mm:ss") + "] " + desc);
        }

        /// <summary>
        /// 清空Log
        /// </summary>
        public static void ClearLog()
        {
            MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
            if (mainWindow != null)
            {
                mainWindow.LogFrame.Items.Clear();
                mainWindow.selText.Text = string.Empty;
            }
        }
    }
}